var token = T.p('token')
	
	var vm = new Vue({
		el:'#rrapp',
		data:{
			listp:[],
			//空气质量
			airQuality:null,
			//今日天气
			weather:null,
			//城市
			area:null,
			//日期
			createTime:'',
			//风向
			fx:'',
			//风力
			windSpeed:'',
			//星期几
			week:'',
		    //今日温度
			low:'',
			high:'',
			future:[],
			tzgg:[],
			
		},
		methods: {
			getlist: function(){
				$.get("../buss/bussfarmlandputinto/list2?token="+token,{'page': 1,'limit': 10},function(r){
					for (var int = 0; int < r.page.list.length; int++) {
						var s = r.page.list[int]
						vm.listp.push(s)
					}
					
					
				})
			},
			//获取通知公告
			gettzgg: function(){
				$.get("../buss/busspublicnotice/list?token="+token,{'page': 1,'limit': 10,'zt':0},function(r){
                     console.log(r.page.list);	
                     vm.tzgg = r.page.list;
					
				})
			},
			//获取温度
			getwd : function(){
				/*获取最新天气*/
				$.get("../buss/bussweatherrecord/list?token="+token,{'page': 1,'limit': 1},function(r){
				     var s = [];
				    // s = r.page.list[0].future.split('}');
				     s = JSON.parse(r.page.list[0].future)
				     vm.weather =  r.page.list[0].weather;
				     vm.area =  r.page.list[0].area;
				     vm.createTime =  r.page.list[0].createTime;
				     vm.fx =  r.page.list[0].fx;
				     vm.windSpeed =  r.page.list[0].windSpeed;
				     vm.low =  r.page.list[0].low;
				     vm.high =  r.page.list[0].high;
				     
				     //vm.future = s;
				     vm.future.push(s[1].type,s[1].ymd,s[1].low.substring(2,s[1].low.length),s[1].high.substring(2,s[1].low.length),
				    		 s[2].type,s[2].ymd,s[2].low.substring(2,s[2].low.length),s[2].high.substring(2,s[2].low.length),
				    		 s[3].type,s[3].ymd,s[3].low.substring(2,s[3].low.length),s[3].high.substring(2,s[3].low.length),
				    		 s[4].type,s[4].ymd,s[4].low.substring(2,s[4].low.length),s[4].high.substring(2,s[4].low.length));
				     //console.log(vm.future);
				})	
			},
			 formatTime: function(dateUnix){
                 var time = new Date(dateUnix).Format("yyyy-MM-dd ");
                 return time;
             },
		},

		mounted:function(){
			this.getlist();
			this.getwd();
			this.gettzgg();
		}	
	});



function GetDateDiff(startTime, endTime, diffType) {
    //将xxxx-xx-xx的时间格式，转换为 xxxx/xx/xx的格式 
    startTime = startTime.replace(/\-/g, "/");
    endTime = endTime.replace(/\-/g, "/");
    //将计算间隔类性字符转换为小写
    diffType = diffType.toLowerCase();
    var sTime =new Date(startTime); //开始时间
    var eTime =new Date(endTime); //结束时间
    //作为除数的数字
    var timeType =1;
    switch (diffType) {
        case"second":
            timeType =1000;
        break;
        case"minute":
            timeType =1000*60;
        break;
        case"hour":
            timeType =1000*3600;
        break;
        case"day":
            timeType =1000*3600*24;
        break;
        default:
        break;
    }
    return parseInt((eTime.getTime() - sTime.getTime()) / parseInt(timeType));
}
//alert(GetDateDiff("2016-03-28 10:30:22","2016-03-28 10:38:22","minute"));
